<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <div id="app">
    <my-cpn></my-cpn>
  </div>
  <div id="app1">
    <my-cpn></my-cpn>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    // 使用组件的步骤
    // 创建组件构造器
    const myComponent = Vue.extend({
      template: `
			<div>
				<h2>组件标题</h2>
				<p>我是组件的内容</p>
				</div>
			`,
    });
    // 注册组件
    Vue.component("my-cpn", myComponent); // 注册为全局组件

    // 使用组件
    const app = new Vue({
      el: "#app",
      data: {
        message: "hello",
      },
    });

    const app1 = new Vue({
      el: "#app1",
    });
  </script>
</body>

</html>